package com.tcrow.config;

import com.jfinal.config.*;
import com.jfinal.ext.route.AutoBindRoutes;
import com.jfinal.log.Log4jLoggerFactory;
import com.tcrow.aop.ExcptionAOP;
import com.tcrow.handler.XssHandler;
import org.apache.log4j.Logger;

/**
 * Created by tcrow on 27/02/2015.
 */
public class Config extends JFinalConfig {

    protected final static Logger logger = Logger.getLogger(Config.class);

    @Override
    public void configConstant(Constants me) {
        loadPropertyFile("database.properties");
        me.setDevMode(getPropertyToBoolean("dev", false));
        //设置日志记录器
        me.setLoggerFactory(new Log4jLoggerFactory());
    }

    @Override
    public void configRoute(Routes me) {
        AutoBindRoutes autoBindRoutes = new AutoBindRoutes();
        me.add(autoBindRoutes);
    }

    @Override
    public void configPlugin(Plugins me) {


    }

    @Override
    public void configInterceptor(Interceptors me) {
        //登录及权限验证拦截器
        me.add(new ExcptionAOP());
    }

    @Override
    public void configHandler(Handlers me) {
        me.add(new XssHandler("update"));
    }

}
